%by clq
%2021/6/12
function[i_R,profits_R]=round_robin(j_all)
global I J
%j_all is the given order of patient types
addpath functions;
n=size(j_all,2);
S=zeros(I,J);

%Step1:find the optimal slot for each patient
for i=1:n
    i_R(i)=mod(i-1,I)+1; 

%Step2:find the profit after each patient is assigned
    j=j_all(i);
    S(i_R(i),j)=S(i_R(i),j)+1;
       Q = findQ(S); 
       R = findR(Q);
       profits_R(i)=function_fQR(Q,R);
end




